home *** CD-ROM | disk | FTP | other *** search
- #include "stdio.h"
-
- FILE *f1,*f2,*fopen();
- static unsigned char linein[256];
- static unsigned char *ap,*cp;
- static int x;
-
- main(argc,argv)
- unsigned int argc;
- unsigned char **argv;
- {
- if (argc != 2){
- printf("\nABORT- Usage: programname infilename\n");
- exit(1);
- }
- if ((f1 = fopen(argv[1], "r")) == NULL){
- printf("\nABORT- Unable to open file: %s\n", argv[1]);
- exit(1);
- }
- ap = "PRN:";
- if ((f2 = fopen(ap, "w")) == NULL){
- printf("\nABORT- Unable to access printer");
- exit(1);
- }
- for (;;){
- if ((fgets(linein,255,f1)) == 0) break;
- if (linein[0] == '1'){
- fputc(0x0c,f2);
- goto detail;
- }
- if (linein[0] == '0'){
- fputc(0x0a,f2);
- fputc(0x0a,f2);
- goto detail;
- }
- if (linein[0] == '-'){
- fputc(0x0a,f2);
- fputc(0x0a,f2);
- fputc(0x0a,f2);
- goto detail;
- }
- if (linein[0] == '+') goto detail;
- fputc(0x0a,f2);
- detail:
- x = strlen(linein);
- cp = &linein[1];
- while (x-- > 2) fputc(*cp++,f2);
- fputc(0x0d,f2);
- }
- fputc(0x0c,f2);
- fclose(f1);
- fclose(f2);
- }
-